<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>菜单管理-菜单列表-后台管理首页-{$site.SITE_INFO.name}</title>
    <php>
        $addCss="";
        $addJs="";
        $currentNav ='菜单管理 > 菜单列表';
    </php>
    <include file="Common:intoHead" />
</head>
<body>
<div class="wrap">
    <include file="Common:head" />
    <div class="mainBody">
        <include file="Common:left" />
        <div id="Right">
            <div class="Item hr">
                <div class="current" style="max-width: 100px; float: left;">菜单管理</div>
                <div style="width: 100px;float: right;"><button type="button" class="btn" onclick="window.location.href='{:U('Siteinfo/add_nav')}'">添加</button></div>
            </div>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab">
                <thead>
                <tr align="center">
                    <td width="6%">原分类CID</td>
                    <td width="15%">原分类结构 <b title="单击分类隐藏/显示该分类下在子类">[i]</b></td>
                    <td width="15%" align="left">操作属性</td>
                    <td width="10%">新分类</td>
                    <td width="10%">排序</td>
                    <td width="15%">修改后的名称</td>
                    <td width="20%">操作</td>
                </tr>
                </thead>
                <tbody>
                <volist name="list" id="tree">
                    <tr pid="{$tree.parent_id}" cid="{$tree.id}">
                        <td  align="center">{$tree.id}<input type="hidden" name="id" value="{$tree.id}"/></td>
                        <td  class="tree" style="cursor: pointer;">{$tree.fullname}</td>
                        <td >
                            <select name="act" class="act">
                                <option selected="selected" value="edit">修改该分类</option>
                                <option value="del">删除该分类</option>
                            </select>
                        </td>
                        <td >
                            <select name="parent_id">
                                <option value="0">顶级分类</option>
                                <volist name="list" id="vo1">
                                    <if condition="$vo1['id'] eq $tree['id']">
                                        <option value="{$vo1.id}" selected="selected" readonly>{$vo1.fullname}</option>
                                        <else/>
                                        <option value="{$vo1.id}">{$vo1.fullname}</option>
                                    </if>
                                </volist>
                            </select>
                        </td>
                        <td >{$tree.sort}</td>
                        <td ><input type="text" value="" name="nav_name" class="input" placeholder="你要修改分类的新名称"/></td>
                        <td align="center" ><button class="btn opCat">确定</button>
                            <button type="button" class="btn" onclick="window.location.href='{:U('Siteinfo/add_nav')}?id={$tree.id}'">编辑</button></td>
                    </tr>
                </volist>
                </tbody>
            </table>
        </div>
    </div>
</div>
<form action="" method="post" id="opForm">
    <input id="cid" type="hidden" name="data[id]" />
    <input id="act" type="hidden" name="act" />
    <input id="pid" type="hidden" name="data[parent_id]" />
    <input id="name" type="hidden" name="data[nav_name]" />
</form>
<div class="clear"></div>
<include file="Common:foot" />
<script type="text/javascript">
    $(function(){
        $(".opCat").click(function(){
            var obj=$(this).parents("tr");
            $("#cid").val(obj.find("input[name='id']").val());
            $("#act").val(obj.find("select[name='act']").val());
            $("#pid").val(obj.find("select[name='parent_id']").val());
            $("#name").val(obj.find("input[name='nav_name']").val());
            if($("#act").val()=="del"){
                popup.confirm('你真的打算删除该分类吗?','温馨提示',function(action){
                    if(action == 'ok'){
                        commonAjaxSubmit("","#opForm");
                    }
                });
                return false;
            }
            commonAjaxSubmit("","#opForm");
        });
        var chn=function(cid,op){
            if(op=="show"){
                $("tr[pid='"+cid+"']").each(function(){
                    $(this).removeAttr("status").show();
                    chn($(this).attr("cid"),"show");
                });
            }else{
                $("tr[pid='"+cid+"']").each(function(){
                    $(this).attr("status",1).hide();
                    chn($(this).attr("cid"),"hide");
                });
            }
        }
        $(".tree").click(function(){
            if($(this).attr("status")!=1){
                chn($(this).parent().attr("cid"),"hide");
                $(this).attr("status",1);
            }else{
                chn($(this).parent().attr("cid"),"show");
                $(this).removeAttr("status");
            }
        });
    });
</script>
</body>
</html>